import React from 'react'
import { IndexBar, Tabs, Cell } from 'react-vant'
import cityData from '../../mock/city'
import { useNavigate } from 'react-router-dom'

const City = () => {
    const navigate=useNavigate()
    const changeCity=(v)=>{
        console.log(v)
        localStorage.setItem('city',JSON.stringify(v))
        navigate('/layout/home')
    }
    return (
                <IndexBar>
                    {cityData && cityData.map(item => (
                        <div key={item}>
                            <IndexBar.Anchor index={item.code} />
                            {
                                item.cityList.map((v,i) => {
                                    return  <Cell title={v} key={i} onClick={()=>{changeCity(v)}}/>
                                })
                            }


                        </div>
                    ))}
                </IndexBar>
           
    )
}
export default City;